//
//  HMSettingViewController.m
//  网易彩票01
//
//  Created by Macx on 16/2/22.
//  Copyright © 2016年 Macx. All rights reserved.
//

#import "HMSettingViewController.h"

@interface HMSettingViewController ()
@property(nonatomic,strong)NSMutableArray *settings;
@end

@implementation HMSettingViewController

-(NSMutableArray *)settings{
    if (_settings==nil) {
        _settings=[NSMutableArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"setting.plist" ofType:nil]];
    }
    return _settings;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    
  self.title=@"设置";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return self.settings.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return [self.settings[section] count]; //还可以这样表示count？
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"settings"];
    
    if ( cell==nil) {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"settings"];
    }
    NSDictionary *dict=self.settings[indexPath.section][indexPath.row];
    
    cell.imageView.image=[UIImage imageNamed:dict[@"icon"]];
    cell.textLabel.text=dict[@"title"];
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    NSDictionary *dict=self.settings[indexPath.section][indexPath.row];
    NSString *destVc=dict[@"desctVc"];
    //将字符串转化成类
    Class clazz=NSClassFromString(destVc);
    UIViewController *vc=[[clazz alloc]init];//??
    [self.navigationController pushViewController:vc animated:YES];

}

@end
